require 'rubygems'
require 'test/unit'
require "sandbox_base_test"

class MagicMethodTest < TestSandbox
	
	def _test_obj( objstr )
		
		assert_raise NoMethodError, RuntimeError do
			self.sandbox.run( "a = #{objstr}
						magic_method = a.public_methods.select{|x| x.size > 20 and x[0..0] == '_'}.first
						a.send(magic_method) do
							system('ls -l')
						end
							"
				)
		end
	end

	def test_methods
		_test_obj "{}"
		_test_obj "1"
		_test_obj "[]"
		_test_obj "''"
		_test_obj "'a'.match(/a/)"
	end

end
